package com.qing.design.patterns.builder.example.cars;

import com.qing.design.patterns.builder.example.components.Engine;
import com.qing.design.patterns.builder.example.components.GPSNavigator;
import com.qing.design.patterns.builder.example.components.Transmission;
import com.qing.design.patterns.builder.example.components.TripComputer;

/**
 * 汽车是一个产品类别。
 */
public class Car {
	//汽车类型
	private final  CarType carType;
	//座位
	private final  int seats;
	//发动机
	private final Engine engine;
   //变速箱
	private final Transmission transmission;
	//车载电脑
	private final TripComputer tripComputer;
   //GPS 导航
	private final  GPSNavigator gpsNavigator;
	//燃油
	private double fuel=0;

	public Car(CarType carType, int seats, Engine engine, Transmission transmission, TripComputer tripComputer, GPSNavigator gpsNavigator) {
		this.carType = carType;
		this.seats = seats;
		this.engine = engine;
		this.transmission = transmission;
		this.tripComputer = tripComputer;
		//车载电脑存在时，将本车注入
		if(this.tripComputer!=null){
			this.tripComputer.setCar(this);
		}
		this.gpsNavigator = gpsNavigator;
	}

	public void setFuel(double fuel) {
		this.fuel = fuel;
	}

	public CarType getCarType() {
		return carType;
	}

	public int getSeats() {
		return seats;
	}

	public Engine getEngine() {
		return engine;
	}

	public Transmission getTransmission() {
		return transmission;
	}

	public TripComputer getTripComputer() {
		return tripComputer;
	}

	public GPSNavigator getGpsNavigator() {
		return gpsNavigator;
	}

	public double getFuel() {
		return fuel;
	}


}
